import java.io.FileReader;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Patron {
    public static void main(String[] args) throws IOException {
        BufferedReader inputStream = null;
        PrintWriter outputStream = null;
        PrintWriter erroresStream = null;

        try {
            inputStream = 
                new BufferedReader(new FileReader(args[0]));
            outputStream = 
                new PrintWriter(new FileWriter(args[1]));
            erroresStream = 
                new PrintWriter(new FileWriter(args[2]));

	    String l;
            while ((l = inputStream.readLine()) != null) {
	    		//Pattern p = Pattern.compile("[^\\.*]@[^.*]\\.[a-z]");
	    		//Pattern p = Pattern.compile("^[^www\\.]^[^\\.@][a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-z]+[^\\.]$");
	    		Pattern p = Pattern.compile("^[^\\.@][a-zA-Z0-9]+@[a-zA-Z0-9]+\\.[a-z]+[^\\.]$");
			Matcher m = p.matcher( l );
	    		Pattern pwww = Pattern.compile("^www\\.");
			Matcher mwww = pwww.matcher( l );
			//boolean found = false;
			if(m.find() && !mwww.find()){
	    			outputStream.println(l);
				System.out.println("Correo sí válido: "+l);
			}
			else{
	    			erroresStream.println(l);
				System.out.println("Correo no válido: "+l);
            		}
	}
	
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
            if (outputStream != null) {
                outputStream.close();
            }
            if (erroresStream != null) {
                erroresStream.close();
            }
        }
    }
}

